home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 May: Tool Chest / Dev.CD May 97 TC.toast / Sample Code / Snippets / Toolbox / Tabs LDEF 1.0 / Sources / Initialize.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-12  |  1.8 KB  |  128 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Initialize.c
  3.     
  4.     Contains:    Initialization code for this application
  5.     
  6.     Written by:    Chris White, Developer Technical Support
  7.     
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9.     
  10.     Change History (most recent first):
  11.     
  12.             12/18/95            CW        First release
  13.  
  14. */
  15.  
  16.  
  17. #pragma segment Initialize
  18.  
  19.  
  20.  
  21. // System includes
  22.  
  23. #ifndef __QUICKDRAW__
  24.     #include <Quickdraw.h>
  25. #endif
  26.  
  27. #ifndef __FONTS__
  28.     #include <Fonts.h>
  29. #endif
  30.  
  31. #ifndef __TEXTEDIT__
  32.     #include <TextEdit.h>
  33. #endif
  34.  
  35. #ifndef __DIALOGS__
  36.     #include <Dialogs.h>
  37. #endif
  38.  
  39. #ifndef __GESTALT__
  40.     #include <Gestalt.h>
  41. #endif
  42.  
  43. #ifndef __SEGLOAD__
  44.     #include <SegLoad.h>
  45. #endif
  46.  
  47.  
  48.  
  49.  
  50. // Application includes
  51.  
  52. #ifndef __BAREBONES__
  53.     #include "BareBones.h"
  54. #endif
  55.  
  56. #ifndef __PROTOTYPES__
  57.     #include "Prototypes.h"
  58. #endif
  59.  
  60.  
  61.  
  62. // static prototypes
  63. static Boolean CheckConfiguration ( void );
  64.  
  65.  
  66.  
  67.  
  68. void InitToolbox ( void )
  69. {    
  70.     
  71.     InitGraf ( &qd.thePort );
  72.     InitFonts ( );
  73.     InitWindows ( );
  74.     InitMenus ( );
  75.     TEInit ( );
  76.     InitDialogs ( nil );
  77.     InitCursor ( );
  78.     
  79.     FlushEvents ( everyEvent, 0 );
  80.     
  81.     return;
  82. }
  83.  
  84.  
  85.  
  86. void InitApplication ( void )
  87. {
  88.     SetMenuBar ( GetNewMBar ( kMenuBarID ) );
  89.     AddResMenu ( GetMHandle ( kAppleMenu ), 'DRVR' );
  90.     DrawMenuBar ( );
  91.     
  92.     if ( !CheckConfiguration ( ) )
  93.     {
  94.         AlertUser ( kNeedSystem7, 0, nil );
  95.         ExitToShell ( );
  96.     }
  97.     
  98.     gQuit = false;                          // Initialize flag that controls main event loop
  99.     gSleepTime = kSleepTime;
  100.     
  101.     InstallAppleEventHandlers ( );
  102.     CreateWindow ( );
  103.     
  104.     return;
  105. }
  106.  
  107.  
  108.  
  109. static Boolean CheckConfiguration ( void )
  110. {
  111.     long        theResult;
  112.     OSErr        theErr;
  113.     Boolean        bHasAppleEvents;
  114.     
  115.     
  116.     // Verify that we can run on the current configuration
  117.     
  118.     // We require AppleEvent Manager and FSSpec-based file traps and Standard File
  119.     theErr = Gestalt ( gestaltAppleEventsAttr, &theResult );
  120.     bHasAppleEvents = (theErr == noErr && (theResult & (1L << gestaltAppleEventsPresent)));
  121.     
  122.     return bHasAppleEvents;
  123. }
  124.  
  125.  
  126.  
  127.  
  128.